package citic;

import java.io.IOException;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.stereotype.Component;
@Component
public abstract class FileTransferAdapter implements FileTransfer {
private static final Log logger = LogFactory.getLog(FileTransferAdapter.class);
	
    private String host;
    private int port;
    private String username;
    private String password;

    public void setHost(String host) {
        this.host = host;
    }

    public void setPort(int port) {
        this.port = port;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    @Override
	public final boolean connect() {
    	logger.info("start connecting:host="+host+"&port="+port+"&username="+username+"&password="+password);
		return connect(host, port, username, password);
	}

    protected abstract boolean connect(String host, int port, String username, String password);

	@Override
	public void disconnect() throws IOException {
	}

	@Override
	public boolean upload(String remote, String local) {
		return false;
	}

	@Override
	public boolean exists(String remote) {
		return false;
	}

	@Override
	public boolean download(String remote, String local) throws IOException {
		return false;
	}

	@Override
	public boolean renameTo(String oldName, String newName) {
		return false;
	}

}
